﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using Hangjing.Common;
using Newtonsoft.Json;
using System.Text;
using System.IO;
using Hangjing.Model;
using Hangjing.DBUtility;
using Hangjing.SQLServerDAL;
using System.Collections.Specialized;

using Hangjing.meituanapi;
using Hangjing.WebCommon;

/// <summary>
/// 新订单，美团调用
/// </summary>
public partial class api_meituan_heartbeat_neworder : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        Response.Clear();
        string order = Server.UrlDecode(Request["order"]);

        //Hangjing.AppLog.AppLog.Info("美团订单来了.美团订单内容：" + order);

        apiResultInfo rs = new apiResultInfo();
        System.IO.Stream stream = Request.InputStream;//这是你获得的流
        if (stream != null && stream.Length > 10)
        {

            Hangjing.AppLog.AppLog.Info("stream.Length ：" + stream.Length);
            string jsondata = "";
            using (StreamReader reader = new StreamReader(stream))
            {
                jsondata = reader.ReadToEnd(); ;
            }

            Hangjing.AppLog.AppLog.Info("美团订单信息：" + jsondata);

            mtorderInfo model = JsonConvert.DeserializeObject<mtorderInfo>(order);

            if (model.ePoiId == "1015")
            {
                mthelper mt = new mthelper(Context);
                apiResultInfo retuls = mt.confirmOrder(model.orderId, Convert.ToInt32(model.ePoiId));
            }

        }
        else
        {
            rs.state = 0;
            rs.msg = "参数错误";
        }

        Response.Write("{\"data\":\"OK\"}");
        Response.End();

    }
}